#[derive(Debug)]
enum Data {
    Inst(Vec<i32>),
    Floats(Vec<f64>),
}
#[derive(Debug)]
struct Array {
    data: Data
}
use std::any::Any;
#[derive(Debug)]
struct Arr {
    data: Box<dyn Any>,
}
fn main(){
    let arrays = vec![
        Array {
            data: Data::Inst(vec![1, 3, 4])
        },
        Array {
            data: Data::Floats(vec![1.00, 3.00, 4.00])
        }
    
    ];
    println!("{arrays:?}");
    let arrs = vec![
        Arr{data: Box::new(vec![1, 2, 3])},
        Arr{data: Box::new([1;3])},
        Arr{data: Box::new(['a', 'b'])}
    ];
    //println!("{arrs:#?}");
    for arr in &arrs {
        match (
            arr.data.downcast_ref::<Vec<i32>>(),
            arr.data.downcast_ref::<[i32; 3]>(),
            arr.data.downcast_ref::<[char; 2]>()
        ) {
            // 按优先级匹配类型
            (Some(v), _, _) => println!("Vec<i32>: {:?}", v),
            (_, Some(v), _) => println!("Array[i32;3]: {:?}", v),
            (_, _, Some(v)) => println!("Array[char;2]: {:?}", v),
            _ => println!("Unknown type"),
        }
    }
}

